# Contributor: Michael Pirogov <vbnet.ru@gmail.com>
# Contributor: Ramanathan Sivagurunathan <ramzthecoder@gmail.com>
# Maintainer: Ramanathan Sivagurunathan <ramzthecoder@gmail.com>
pkgname=filebeat
pkgver=7.14.0
pkgrel=6
pkgdesc="Lightweight Shipper for Logs"
pkgusers="root"
url="https://www.elastic.co/products/beats"
# riscv64: https://github.com/elastic/go-concert/issues/51
arch="all !armhf !armv7 !aarch64 !riscv64"
license="Apache-2.0"
makedepends="go"
subpackages="$pkgname-openrc"
options="!check chmod-clean" # No test suite
source="beats-$pkgver.tar.gz::https://github.com/elastic/beats/archive/v$pkgver.tar.gz
	filebeat.initd
	filebeat.confd
	filebeat.yml
	"
builddir="$srcdir/src/github.com/elastic/beats/$pkgname"

prepare() {
	mkdir -p "$srcdir/src/github.com/elastic/"
	mv "$srcdir/beats-$pkgver" "$srcdir/src/github.com/elastic/beats"
	default_prepare
}

build() {
	GOPATH="$srcdir" go build -v
}

package() {
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 "$srcdir/filebeat.yml" "$pkgdir/etc/$pkgname/filebeat.yml"
	install -Dm755 "$builddir/filebeat" "$pkgdir/usr/bin/filebeat"
}

sha512sums="
78032aebcd5f012a3c348c45440a9bb0509cc76e576ac99a9017294f18aedcadff7b24775abbcfaa96cf72293e2dc4445177aef6f3d48e1fa69f29b9b9972336  beats-7.14.0.tar.gz
782ea2a2a5056e9e4d2e4ef6bb3f416b4ab0aba8486a7115e586b735478b53f75246af8ac5a6e10f93da6773854220dec7125396fa2fc24edeb1ddc0ea2f4ba1  filebeat.initd
d39f6264d44d34958f005652cae6ffeed3bb66aea7694c5cd1c9d1e00befda946522d54d7138d7bafa30314588bc44b84f12b5bb1beac65553b69de3d91c34ad  filebeat.confd
b0d5fa1d37041a4f1383451107abcdab1ce15ed537f702f55756f59c2110445dcddaf7c58f2a0561e18b83e3cab72fceb9d931bae9267f1acd9d35135555d6f7  filebeat.yml
"
